package com.neuedu.dao.impl;

import com.neuedu.dao.UserDao;
import com.neuedu.model.User;
import com.neuedu.utils.DBUtil;

import java.util.List;

public class UserDaoImpl implements UserDao {

    @Override
    public int updateUserByIdSelective(User user) {
        return DBUtil.updateSelective(user,"id=?",user.getId());
    }

    @Override
    public User selectUser(Integer userId) {

        return DBUtil.findOneByWhere(User.class,"id=?",userId);
    }

    @Override
    public User selectUserByUnameAndPwd(String username, String password) {
        return DBUtil.findOneByWhere(User.class,"username=? and password=?" ,username,password);
    }

    @Override
    public List<User> selectAll() {

        return DBUtil.findAll(User.class);
    }
}
